package com.base.dao;

import java.io.*;
import java.sql.Blob;
import java.sql.SQLException;

import org.hibernate.Criteria;
import org.hibernate.Hibernate;
import org.hibernate.criterion.Restrictions;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import tool.JsonTool;

import com.base.bean.*;

/**
 * 
 * @author Administrator
 *
 */
public class SessionObjDao extends _BaseDao<SessionObj>{
	
	
	 
	        
	    public static void  main(String[] args) throws Exception{
	    	
//	    	保存一个对象到SessonOBj表中  该对象json化
//	    	SessionObjDao sd = (SessionObjDao) _BaseDao.ac.getBean("SessionObjDao");
//	    	SessionObj so = new SessionObj(1, "user", 1,1, 1);    	
//	    	User u = new User(1,"userName");
//	    	so.setObjJson(u);
//	    	sd.merge(so);
	    	
//	    	取出json对象
	    	SessionObjDao sd = (SessionObjDao) _BaseDao.ac.getBean("SessionObjDao");
	    	SessionObj so = sd.findByHql("from SessionObj o where o.sid=1").get(0);
	    	String json = so.getObjJson();
	    	User u = JsonTool.json2pojo(json,User.class);
	    	System.out.println(u.getUid()+"|"+u.getName());
	    }
	      
}
